/*
 *  Copyright 2012 Ricardo Engel
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.mookt.unit.currency;

import java.util.Collection;

/**
 * Responsible for providing {@link CurrencyUnit} instances to its factory
 * methods.
 * 
 * <p>
 * The actual provider being used by the {@link CurrencyUnit} defined by the
 * following JVM switch:
 * 
 * <pre>
 * -Dorg.mookt.unit.currency.CurrencyUnitProvider=<class path>
 * </pre>
 * 
 * </p>
 * 
 * @author Ricardo Engel
 */
public interface Provider {

    /**
     * Obtains an instance of {@code CurrencyUnit} for the specified ISO-4217
     * three letter currency code.
     * 
     * <p>
     * A currency is uniquely identified by ISO-4217 three letter code.
     * </p>
     * 
     * @param code the currency code, not null
     * @return the singleton instance, never null
     * @throws IllegalCurrencyException if the currency is unknown
     */
    CurrencyUnit get(String code);

    /**
     * Obtains an instance of {@code CurrencyUnit} for the specified ISO-4217
     * numeric currency code.
     * 
     * <p>
     * The numeric code is an alternative to the three letter code.
     * </p>
     * 
     * @param numericCode the numeric currency code, not null
     * @return the singleton instance, never null
     * @throws IllegalCurrencyException if the currency is unknown
     */
    CurrencyUnit get(short numericCode);

    /**
     * Gets the list of all available currencies.
     * 
     * <p>
     * This class only permits known currencies to be returned, thus this list
     * is the complete list of valid singleton currencies. The list may change
     * after application startup, however this isn't recommended.
     * </p>
     * 
     * @return the sorted, independent, list of all registered currencies, never
     *         null
     */
    Collection<CurrencyUnit> getAll();

}
